<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>
<script type="text/javascript">
<!--


var selectType = "${param['selectType']}";	//列表选择类型：checkbox或radio
var onSelect="${param['onSelect']}";		//选中时的响应函数 参数是一个商品的JSON对象
var action = "${ctx }/crm/goods!selectGoods.action";

//初始化，将参数加至actionURL中，防止翻页丢失
function init(){
	var url = action;
	url+="?";
	url+="&selectType="+selectType;
	url+="&onSelect="+onSelect;
	$(".selectGoodsForm").attr("action",url);
}
//选择完毕
function selectOK(){
	$.pdialog.closeCurrent();
}

//全选和反选
var toggle = false;
function selectAll(){

}


//按字段名，返回字段值
function field(fieldName,tr){
	return $("."+fieldName,tr).val();
}

//单选，调用响应函数后关闭
function singleSelect(){
	var ctrl = event.srcElement;
	var id = ctrl.value;
	var tr = $(ctrl).parents("tr");
	var goods = "{";
	goods+="id:"+id;
	$("input[type='hidden']",tr).each(function(){
		goods+=",";
		var val = "'"+this.value+"'";
		goods+=this.className+":"+val;
		});
	goods+="}";
	eval(onSelect+"("+goods+");");
	$.pdialog.closeCurrent();
}
$(document).ready(function(){
	init();
});
//-->
</script>
<form id="pagerForm"  class="selectGoodsForm" method="post" action="${ctx }/crm/goods!selectGoods.action">
	<input type="hidden" name="status" value="${param.status}">
	<input type="hidden" name="keywords" value="${param.keywords}" />
	<input type="hidden" name="pageNum"  value="${page.pageNo}" />
	<input type="hidden" name="numPerPage" id="numPerPage" value="${page.pageSize}" />
	<input type="hidden" name="orderField" value="${param.orderField}" />
	<input type="hidden" name="page.pageNo" id="pageNo" value="${page.pageNo}"/>
	<input type="hidden" name="page.orderBy" id="orderBy" value="${page.orderBy}"/>
	<input type="hidden" name="page.order" id="order" value="${page.order}"/>
	<input type="hidden" name="page.pageSize" id="pageSize" value="${page.pageSize}"/>
</form>

<div class="page">
	<div class="pageHeader">
		<form class="selectGoodsForm" onsubmit="return dialogSearch(this);" action="${ctx }/crm/goods!selectGoods.action" method="post">		
		<div class="searchBar">
			<ul class="searchContent">
				<li>
					<label>产品名称：</label>
					<input type="text" name="filter_LIKES_pname" value="${param['filter_LIKES_pname']}"/>
				</li>
				<li>
					<label>售价：</label>
					<input type="text" name="filter_GEN_price" value="${param['filter_GEL_price']}" size="5"/> 至
					<input type="text" name="filter_LEN_price" value="${param['filter_LEL_price']}" size="5"/>
				</li>
				<li>
					<label>型号：</label>
					<input type="text" name="filter_LIKES_model" value="${param['filter_LIKES_model']}"/>
				</li>
			</ul>
			<div class="subBar">
				<ul>
					<li><div class="buttonActive"><div class="buttonContent"><button type="submit"> 检 索 </button></div></div></li>
					<li><div class="buttonActive"><div class="buttonContent"><button type="button" onclick="selectOK()"> 确 定  </button></div></div></li>
				</ul>
			</div>
		</div>
		</form>
	</div>
	<div class="pageContent">
		
			<table class="table" layouth="142">
			<thead>
				<tr>
				<th>选择</th>
				<th>产品简称</th>
				<th>型号</th>
				<th>单位</th>
				<th>重量</th>
				<th>单价</th>
				<th>系列</th>
				<th>类别</th>
				</tr>
			</thead>
			<tbody>
				<s:iterator value="page.result">
					<tr target="selectedId" rel="${id}">
						<td><input type="${param['selectType']}" name="ctrl" id="${id}" value="${id}" onclick="singleSelect();" /></td>
						<td><input type="hidden" class="pname" value="${pname}"/><input type="hidden" class="shortname" value="${shortname}"/>${shortname}</td>
						<td><input type="hidden" class="model" value="${model}"/>${model}</td>
						<td><input type="hidden" class="unit" value="${unit}"/>${unit}</td>
						<td><input type="hidden" class="weight" value="${weight}"/>${weight}</td>
						<td><input type="hidden" class="price" value="${price}"/><s:if test="price!=null"><s:text name="global.format.money"><s:param value="price"/></s:text></s:if></td>
						<td><input type="hidden" class="cate_parent_name" value="${cate.parent.name}"/>${cate.parent.name}</td>
						<td><input type="hidden" class="cate_name" value="${cate.name}"/>${cate.name}</td>
					</tr>
		</s:iterator>	
			</tbody>
		</table>
		<div class="panelBar">
			<div class="pages">
				<span>显示</span>
				<select name="numPerPage" id="showNumPerPage" onchange="dialogPageBreak({numPerPage:this.value})">
					<option value="14">14</option>
					<option value="20">20</option>
					<option value="50">50</option>
					<option value="100">100</option>
				</select>
				<span>条，共${page.totalCount}条</span>
			</div>
			
			<div class="pagination" targetType="dialog" totalCount="${page.totalCount}" numPerPage="${page.pageSize}" pageNumShown="10" currentPage="${page.pageNo}"></div>

		</div>
	</div>
</div>
